package com.ccrego.haiyi.quickysee;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ccrego.haiyi.R;
import com.ccrego.haiyi.app.MainActivity;
import com.ccrego.haiyi.utils.FragmentUtils;
import com.pachong.android.baseuicomponent.activity.BaseActivity;


/**
 * Description:
 * Created by Andy Hong on 10/16/2017.
 */

public class QuickSeeActivity extends BaseActivity {
    private QuickSeeFragment quickSeeFragment;

    public static void start(Context context) {
        Intent intent = new Intent(context, QuickSeeActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        quickSeeFragment = new QuickSeeFragment();
        FragmentUtils.replaceFragment(getSupportFragmentManager(), R.id.fl_container,quickSeeFragment);
        setTitle("快看");
        getCustomToolbar().setBackgroundColor(Color.parseColor("#44C253"));
        getCustomToolbar().addLeftImageButton(R.mipmap.icon_back, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MainActivity.start(QuickSeeActivity.this);
                finish();
            }
        });


    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.activity_quicksee, null);
    }



    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            MainActivity.start(QuickSeeActivity.this);
            finish();
            return false;
        }else {
            return super.onKeyDown(keyCode, event);
        }
    }
}
